package com.sosee.cgfw.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sosee.cgfw.R;
import com.sosee.cgfw.entity.BrandJson;
import com.sosee.cgfw.entity.JsonData;
import com.sosee.cgfw.utils.Constans;
import com.sosee.cgfw.utils.LogUtils;
import com.sosee.cgfw.utils.Utils;
import com.lidroid.xutils.BitmapUtils;
import com.umeng.analytics.MobclickAgent;

import java.util.List;

/**
 * Created by Thinkpad on 2016/2/18.
 * 品牌详情页
 */
public class BrandDetailActivity extends Activity implements View.OnClickListener {
    private TextView tv_info;
    private RelativeLayout rl_zhankai;
    private RelativeLayout rl_info;
    private RelativeLayout rl_xiangshang;
    private String key;//接收 传递来的数据
    private LinearLayout ig_back;//背景图片
    private BitmapUtils bitmapUtils;

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_branddetial);
        initView();
        initData();
    }


    public void initView(){
        bitmapUtils=new BitmapUtils(this);
        ig_back= (LinearLayout) findViewById(R.id.ig_back);
        tv_info= (TextView) findViewById(R.id.tv_info);
        rl_info= (RelativeLayout) findViewById(R.id.rl_info);
        rl_zhankai= (RelativeLayout) findViewById(R.id.rl_zhankai);
        rl_xiangshang= (RelativeLayout) findViewById(R.id.rl_xiangshang);
        rl_xiangshang.setOnClickListener(this);
        rl_zhankai.findViewById(R.id.rl_xiangxia).setOnClickListener(this);
//        rl_info.setAlpha(0.5f);
//        tv_info.setAlpha(1);
    }

    public void initData(){
        key=getIntent().getStringExtra("key");
        BrandJson bj= Utils.bran_list.get(key);
        tv_info.setText(bj.getData().getInfo());
        bitmapUtils.display(ig_back, Constans.BASE_URL+key+"back.jpg");
    }

    @Override
    public void onClick(View v) {
        int id=v.getId();
        switch (id){
            case R.id.rl_xiangshang:
                rl_zhankai.setVisibility(View.VISIBLE);
                rl_xiangshang.setVisibility(View.GONE);
                break;
            case R.id.rl_xiangxia:
                rl_zhankai.setVisibility(View.GONE);
                rl_xiangshang.setVisibility(View.VISIBLE);
                break;
        }
    }

    //回退事件
    public void back(View view){
        finish();
    }

    //跳转袖长详情页
    public void show(View v){
        Intent intent=new Intent(this,ScheduleDetailActivity.class);
        List<JsonData> slist=Utils.bran_list.get(key).getData().getShow();
        if(slist!=null&& slist.size()>0){
            JsonData data=slist.get(0);
            intent.putExtra("detail",data);
            intent.putExtra("key",key);
            int from=1;
            intent.putExtra("from",from);
            startActivity(intent);
        }else{
            Utils.showToast("对不起，该品牌暂无秀场信息");
        }

    }
}
